package com.zuoye.String;

/**
 * @version v1.0
 * @Description
 * @Author admin
 * @date 2021/7/20  9:15
 * @Copyright
 */
public class Zuoye {


    public static void main(String[] args) {
        String str1 = "klhfsahladfhjkadgkljadslfhsadfhsfdlkjsaklfhjsadladsj";
        String str2 = "dfufhjkmnopdf";
        String max = "";
        for (int i = 0; i < str2.length(); i++) {
            for (int j = 0, z = str2.length() - i; z != str2.length() + 1; z++, j++) {
                if (str1.contains(str2.substring(j, z))) {
                    if (str2.substring(j, z).length() > max.length()) {
                        max= str2.substring(j, z);
                    }

                }
            }

        }
        System.out.println(max);
    }
}
